<!DOCTYPE html>
<html lang="zh-Hans">
  <head>
    
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">



  <meta name="description" content="OSX这种GUI和shell完美结合的系统实在是程序员的最爱,自从工作环境切换到了OSX,就迫不及待的折腾了一番,借着这次升级OSX 10.11的机会,记录一下各种装开发环境的姿势."/>




  <meta name="keywords" content="PHP, OSX, 杂鱼君的博客" />










  <link rel="alternate" href="/atom.xml" title="杂鱼君的博客">




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=2.6.0" />



<link rel="canonical" href="http://notes.wen.moe/post/osx-lnmp.html"/>


<link rel="stylesheet" type="text/css" href="/css/style.css?v=2.6.0" />



  <link rel="stylesheet" type="text/css" href="/lib/fancybox/jquery.fancybox.css" />




  



  <script id="baidu_push">
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>









    <title> 在OSX上安装php开发环境 - 杂鱼君的博客 </title>
  </head>

  <body><div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/." class="logo">杂鱼君的博客</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>

<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    
      <a href="/">
        <li class="mobile-menu-item">
          
          
            Home
          
        </li>
      </a>
    
      <a href="/archives/">
        <li class="mobile-menu-item">
          
          
            Archives
          
        </li>
      </a>
    
      <a href="/tags">
        <li class="mobile-menu-item">
          
          
            Tags
          
        </li>
      </a>
    
      <a href="/about">
        <li class="mobile-menu-item">
          
          
            About
          
        </li>
      </a>
    
  </ul>
</nav>

    <div class="container" id="mobile-panel">
      <header id="header" class="header"><div class="logo-wrapper">
  <a href="/." class="logo">杂鱼君的博客</a>
</div>

<nav class="site-navbar">
  
    <ul id="menu" class="menu">
      
        <li class="menu-item">
          <a class="menu-item-link" href="/">
            
            
              Home
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/archives/">
            
            
              Archives
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/tags">
            
            
              Tags
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/about">
            
            
              About
            
          </a>
        </li>
      
    </ul>
  
</nav>

      </header>

      <main id="main" class="main">
        <div class="content-wrapper">
          <div id="content" class="content">
            
  
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          在OSX上安装php开发环境
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-12-29
        </span>
        
        
      </div>
    </header>

    
    
  <div class="post-toc" id="post-toc">
    <h2 class="post-toc-title">Contents</h2>
    <div class="post-toc-content">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#一些准备工作"><span class="toc-text">一些准备工作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#安装Xcode"><span class="toc-text">安装Xcode</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#安装homebrew"><span class="toc-text">安装homebrew</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装iterm-和-Oh-My-Zsh"><span class="toc-text">安装iterm 和 Oh-My-Zsh</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#自动安装"><span class="toc-text">自动安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#手动安装"><span class="toc-text">手动安装</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装php"><span class="toc-text">安装php</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#修改环境变量"><span class="toc-text">修改环境变量</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装php相关的拓展"><span class="toc-text">安装php相关的拓展</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装nginx"><span class="toc-text">安装nginx</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#nginx-conf的一些配置"><span class="toc-text">nginx.conf的一些配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装mysql"><span class="toc-text">安装mysql</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装其他组件"><span class="toc-text">安装其他组件:</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#redis"><span class="toc-text">redis</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#memcached"><span class="toc-text">memcached</span></a></li></ol></li></ol>
    </div>
  </div>


    <div class="post-content">
      
        <h2 id="一些准备工作"><a href="#一些准备工作" class="headerlink" title="一些准备工作"></a>一些准备工作</h2><h3 id="安装Xcode"><a href="#安装Xcode" class="headerlink" title="安装Xcode"></a>安装Xcode</h3><p>首先必须要安装xcode,通过Mac appStore就可以.然后还要注意安装code命令行工具:</p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></div></pre></td></tr></table></figure>
<p>安装好了以后记得先手动打开一次xcode,同意一下用户协议.</p>
<h3 id="安装homebrew"><a href="#安装homebrew" class="headerlink" title="安装homebrew"></a>安装homebrew</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/<span class="keyword">install</span>/<span class="keyword">master</span>/<span class="keyword">install</span>)<span class="string">"</span></div></pre></td></tr></table></figure>
<p>添加几个官方的软件源</p>
<figure class="highlight armasm"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span>tap homebrew/dupes</div><div class="line"><span class="keyword">brew </span>tap homebrew/versions</div><div class="line"><span class="keyword">brew </span>tap homebrew/php</div></pre></td></tr></table></figure>
<h2 id="安装iterm-和-Oh-My-Zsh"><a href="#安装iterm-和-Oh-My-Zsh" class="headerlink" title="安装iterm 和 Oh-My-Zsh"></a>安装iterm 和 Oh-My-Zsh</h2><p>iterm 是很好用的命令行工具,这个可以直接去<a href="http://www.iterm2.com" target="_blank" rel="external">官网</a> 下载安装.</p>
<p>zsh是非常复杂强大的shell,而Oh-My-Zsh又是非常简单易用的zsh.所以…</p>
<h3 id="自动安装"><a href="#自动安装" class="headerlink" title="自动安装"></a>自动安装</h3><figure class="highlight awk"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">wget https:<span class="regexp">//gi</span>thub.com<span class="regexp">/robbyrussell/</span>oh-my-zsh<span class="regexp">/raw/m</span>aster<span class="regexp">/tools/i</span>nstall.sh -O - | sh</div></pre></td></tr></table></figure>
<p><em>不过OSX貌似没有自带wget,所以需要 brew去装一个</em></p>
<h3 id="手动安装"><a href="#手动安装" class="headerlink" title="手动安装"></a>手动安装</h3><figure class="highlight crystal"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">git clone <span class="symbol">git:</span>/<span class="regexp">/github.com/robbyrussell</span><span class="regexp">/oh-my-zsh.git ~/</span>.oh-my-zsh</div><div class="line">cp ~<span class="regexp">/.oh-my-zsh/templates</span><span class="regexp">/zshrc.zsh-template ~/</span>.zshrc</div></pre></td></tr></table></figure>
<p>安装好了以后需要退出当前的shell,重开你的iterm就能使用强大的Oh-My-Zsh了.</p>
<p><strong>zsh 的配置文件位于 ~/.zshrc</strong>,可以先尝试着去修改一下主题什么的,慢慢摸索.</p>
<h2 id="安装php"><a href="#安装php" class="headerlink" title="安装php"></a>安装php</h2><p>因为我们使用的ngnix,所以在安装的时候要注意编译fpm以及禁用apache:</p>
<figure class="highlight haml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">brew install php56 \</div><div class="line">-<span class="ruby">-without-snmp \</span></div><div class="line"><span class="ruby">--without-apache \</span></div><div class="line"><span class="ruby">--with-fpm \</span></div><div class="line"><span class="ruby">--with-intl \</span></div><div class="line"><span class="ruby">--with-homebrew-curl \</span></div><div class="line"><span class="ruby">--with-homebrew-libxslt \</span></div><div class="line"><span class="ruby">--with-homebrew-openssl \</span></div><div class="line"><span class="ruby">--with-imap \</span></div><div class="line"><span class="ruby">--with-mysql \</span></div><div class="line"><span class="ruby">--with-tidy</span></div></pre></td></tr></table></figure>
<p>安装好了以后注意看说明,brew会提示如何把php加入开机启动:</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">ln -sfv <span class="string">/usr/local/opt/php56/</span>*<span class="string">.plist</span> ~<span class="string">/Library/LaunchAgents</span></div><div class="line"></div><div class="line">launchctl load ~<span class="string">/Library/LaunchAgents/homebrew.mxcl.php56.plist</span></div></pre></td></tr></table></figure>
<h3 id="修改环境变量"><a href="#修改环境变量" class="headerlink" title="修改环境变量"></a>修改环境变量</h3><p>由于系统已经自带了php环境,因此我们需要修改环境变量,优先执行我们安装的php版本,修改<code>~/.zshrc</code> 文件:</p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="builtin-name">export</span> <span class="attribute">PATH</span>=<span class="string">"/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"</span></div></pre></td></tr></table></figure>
<p>然后让配置生效:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">source</span> ./zshrc</div></pre></td></tr></table></figure>
<p>这时候我们再通过<code>php -v</code> 和 <code>php-fpm -v</code> 查看,就能发现运行的是我们安装的php版本了.</p>
<p><em>brew 安装的php有时候会带有一个bug,当发起https请求的时候会报错.这时候需要我们重新安装openssl:</em></p>
<figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span>rm curl</div><div class="line"><span class="keyword">brew </span>update</div><div class="line"><span class="keyword">brew </span><span class="keyword">install </span>—with-openssl curl</div></pre></td></tr></table></figure>
<p><em>再重启一下fpm就可以了.</em></p>
<h2 id="安装php相关的拓展"><a href="#安装php相关的拓展" class="headerlink" title="安装php相关的拓展"></a>安装php相关的拓展</h2><figure class="highlight smali"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">brew install php56-gearman php56-msgpack php56-memcache php56-memcached php56-mongo php56-redis php56-xdebug</div></pre></td></tr></table></figure>
<p><em>由于众所周知的原因brew经常出现下载失败的状况,一般只要重新下载就可以了.但是有时候会报某个包不存在,但是手动 brew install 却提示已经安装的情况.这时候就需要brew uninstall xxx 之后再 brew install xxx 就可以了</em></p>
<h2 id="安装nginx"><a href="#安装nginx" class="headerlink" title="安装nginx"></a>安装nginx</h2><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span><span class="keyword">install </span>nginx</div></pre></td></tr></table></figure>
<p>同样根据提示,加入开机启动:</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">ln -sfv <span class="string">/usr/local/opt/nginx/</span>*<span class="string">.plist</span> ~<span class="string">/Library/LaunchAgents</span></div><div class="line"></div><div class="line">launchctl load ~<span class="string">/Library/LaunchAgents/homebrew.mxcl.nginx.plist</span></div></pre></td></tr></table></figure>
<p>nginx 安装后只能监听非80端口,监听80端口候需要给予root权限(注意路径的版本号,有可能不同):</p>
<figure class="highlight groovy"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">sudo chown <span class="string">root:</span>wheel <span class="regexp">/usr/</span>local<span class="regexp">/Cellar/</span>nginx<span class="regexp">/1.8.0/</span>bin/nginx</div><div class="line">sudo chmod u+s <span class="regexp">/usr/</span>local<span class="regexp">/Cellar/</span>nginx<span class="regexp">/1.8.0/</span>bin/nginx</div></pre></td></tr></table></figure>
<h3 id="nginx-conf的一些配置"><a href="#nginx-conf的一些配置" class="headerlink" title="nginx.conf的一些配置"></a>nginx.conf的一些配置</h3><p>我们可以仿照ubuntu下的nginx的文件夹配置:</p>
<figure class="highlight stata"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">mkdir</span> -p /usr/<span class="keyword">local</span>/etc/nginx/sites-available</div><div class="line"><span class="keyword">mkdir</span> -p /usr/<span class="keyword">local</span>/etc/nginx/<span class="keyword">conf</span></div></pre></td></tr></table></figure>
<p>然后修改<code>/usr/local/etc/nginx/nginx.conf</code>文件:</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#user  nobody;</span></div><div class="line"><span class="attribute">worker_processes</span>  <span class="number">1</span>;</div><div class="line"></div><div class="line"><span class="comment">#指定error.log的路径</span></div><div class="line"><span class="attribute">error_log</span>  /usr/local/var/log/nginx/error.log <span class="literal">debug</span>;</div><div class="line"></div><div class="line"><span class="comment">#pid        logs/nginx.pid;</span></div><div class="line"></div><div class="line"><span class="section">events</span> &#123;</div><div class="line">    <span class="attribute">worker_connections</span>  <span class="number">256</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="section">http</span> &#123;</div><div class="line">    <span class="attribute">include</span>       mime.types;</div><div class="line">    <span class="attribute">default_type</span>  application/octet-stream;</div><div class="line">    <span class="attribute">log_format</span> main <span class="string">'<span class="variable">$remote_addr</span> - <span class="variable">$remote_user</span> [<span class="variable">$time_local</span>] '</span></div><div class="line">        <span class="string">'"<span class="variable">$request</span>" <span class="variable">$status</span> <span class="variable">$body_bytes_sent</span> '</span></div><div class="line">        <span class="string">'"<span class="variable">$http_referer</span>" "<span class="variable">$http_user_agent</span>" '</span></div><div class="line">        <span class="string">'"<span class="variable">$http_x_forwarded_for</span>" <span class="variable">$host</span> <span class="variable">$request_time</span> <span class="variable">$upstream_response_time</span> <span class="variable">$scheme</span> '</span></div><div class="line">        <span class="string">'<span class="variable">$cookie_evalogin</span>'</span>;</div><div class="line"></div><div class="line"><span class="comment">#指定access.log的路径</span></div><div class="line">    <span class="attribute">access_log</span>  /usr/local/var/log/nginx/access.log  main;</div><div class="line"></div><div class="line">    <span class="attribute">sendfile</span>        <span class="literal">on</span>;</div><div class="line">    <span class="attribute">keepalive_timeout</span>  <span class="number">65</span>;</div><div class="line">    <span class="comment">#gzip  on;</span></div><div class="line">    <span class="attribute">port_in_redirect</span> <span class="literal">off</span>;</div><div class="line"></div><div class="line"></div><div class="line">    <span class="attribute">include</span> /usr/local/etc/nginx/sites-enabled/*;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>然后<code>/usr/local/etc/nginx/site-enabled/</code>目录可以N个配置文件对应N个项目了,比如一个local.conf文件:</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="section">server</span> &#123;</div><div class="line">    <span class="attribute">listen</span>       <span class="number">80</span>;</div><div class="line">    <span class="attribute">server_name</span>  localhost;</div><div class="line">    <span class="attribute">root</span>         /Users/evanszhang/develop;</div><div class="line">    <span class="attribute">index</span> index.php;</div><div class="line"></div><div class="line">    <span class="attribute">location</span> <span class="regexp">~ \.php</span> &#123;</div><div class="line">        <span class="attribute">include</span> fastcgi_params;</div><div class="line">        <span class="attribute">fastcgi_buffers</span> <span class="number">128</span> <span class="number">4k</span>;</div><div class="line">        <span class="attribute">fastcgi_pass</span>   <span class="number">127.0.0.1:9000</span>;</div><div class="line">        <span class="attribute">fastcgi_index</span>  index.php;</div><div class="line">        <span class="attribute">fastcgi_param</span>  SCRIPT_FILENAME  /home/larablog/public<span class="variable">$fastcgi_script_name</span>;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>最后用root启动nginx:</p>
<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="attribute">sudo nginx</span></div></pre></td></tr></table></figure>
<h2 id="安装mysql"><a href="#安装mysql" class="headerlink" title="安装mysql"></a>安装mysql</h2><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span><span class="keyword">install </span>mysql</div></pre></td></tr></table></figure>
<p>同样最好也是开机启动</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">ln -sfv <span class="string">/usr/local/opt/mysql/</span>*<span class="string">.plist</span> ~<span class="string">/Library/LaunchAgents</span></div><div class="line"></div><div class="line">launchctl load ~<span class="string">/Library/LaunchAgents/homebrew.mxcl.mysql.plist</span></div></pre></td></tr></table></figure>
<p>通过以下命令为mysql的root用户设置一个密码:</p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="attribute">mysqladmin</span> -uroot password <span class="string">"mypassword"</span></div></pre></td></tr></table></figure>
<h2 id="安装其他组件"><a href="#安装其他组件" class="headerlink" title="安装其他组件:"></a>安装其他组件:</h2><h3 id="redis"><a href="#redis" class="headerlink" title="redis"></a>redis</h3><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span><span class="keyword">install </span>redis</div></pre></td></tr></table></figure>
<p>设置开机启动:</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">ln -sfv <span class="string">/usr/local/opt/redis/</span>*<span class="string">.plist</span> ~<span class="string">/Library/LaunchAgents</span></div><div class="line"></div><div class="line">launchctl load ~<span class="string">/Library/LaunchAgents/homebrew.mxcl.redis.plist</span></div></pre></td></tr></table></figure>
<p>修改配置文件,允许以守护进程执行:</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vim <span class="regexp">/usr/</span>local<span class="regexp">/etc/</span>redis.conf</div></pre></td></tr></table></figure>
<p>设置<code>daemonize</code>的值为<code>yes</code></p>
<p>如果想手动启动redis,可以执行以下命令:</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis-server <span class="regexp">/usr/</span>local<span class="regexp">/etc/</span>redis.conf</div></pre></td></tr></table></figure>
<h3 id="memcached"><a href="#memcached" class="headerlink" title="memcached"></a>memcached</h3><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">brew </span><span class="keyword">install </span>memcached</div></pre></td></tr></table></figure>
<p>设置开机启动:</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ln -sfv <span class="string">/usr/local/opt/memcached/</span>*<span class="string">.plist</span> ~<span class="string">/Library/LaunchAgents</span></div><div class="line">launchctl load ~<span class="string">/Library/LaunchAgents/homebrew.mxcl.memcached.plist</span></div></pre></td></tr></table></figure>
<p>以上安装完成.</p>

      
    </div>

    
      
      

  <div class="post-copyright">
    <p class="copyright-item">
      <span>Author: </span>
      <a href="http://notes.wen.moe">zakokun</a>
    </p>
    <p class="copyright-item">
      <span>Link: </span>
      <a href="http://notes.wen.moe/post/osx-lnmp.html">http://notes.wen.moe/post/osx-lnmp.html</a>
    </p>
    <p class="copyright-item">
      <span>License: </span>
      
      <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>
    </p>
  </div>



      
      
    

    
      <footer class="post-footer">
        
          <div class="post-tags">
            
              <a href="/tags/PHP/">PHP</a>
            
              <a href="/tags/OSX/">OSX</a>
            
          </div>
        
        
        
  <nav class="post-nav">
    
      <a class="prev" href="/post/2015-year-person-summarize.html">
        <i class="iconfont icon-left"></i>
        <span class="prev-text nav-default">2015年终总结</span>
        <span class="prev-text nav-mobile">Prev</span>
      </a>
    
    
      <a class="next" href="/post/sony-a7r2-camera-with-e55-e1635-lens.html">
        <span class="next-text nav-default">一脚跨入全画幅!SONY A7R2+E55+E1635开箱</span>
        <span class="prev-text nav-mobile">Next</span>
        <i class="iconfont icon-right"></i>
      </a>
    
  </nav>

      </footer>
    

  </article>


          </div>
          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
      </main>

      <footer id="footer" class="footer">

  <div class="social-links">
    
      
        
          <a href="mailto:me@wen.moe" class="iconfont icon-email" title="email"></a>
        
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
        
          <a href="https://www.instagram.com/zakokun" class="iconfont icon-instagram" title="instagram"></a>
        
      
    
    
    
  </div>


<div class="copyright">
  <span class="power-by">
    Powered by <a class="hexo-link" href="https://hexo.io/">Hexo</a>
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    Theme -
    <a class="theme-link" href="https://github.com/ahonn/hexo-theme-even">Even</a>
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    Hosted by <a class="theme-link" href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a>
  </span>

  <span class="copyright-year">
    
    &copy;
    
      2014 -
    
    2017

    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">zakokun</span>
  </span>
</div>

      </footer>

      <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
      </div>
    </div>

    
  
  <script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'http://notes.wen.moe/post/osx-lnmp.html';
        this.page.identifier = 'post/osx-lnmp.html';
        this.page.title = '在OSX上安装php开发环境';
    };
    (function() {
    var d = document, s = d.createElement('script');

    s.src = '//evanszhang.disqus.com/embed.js';

    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
    })();  
  </script>




    
  





  
    <script type="text/javascript" src="/lib/jquery/jquery-3.1.1.min.js"></script>
  

  
    <script type="text/javascript" src="/lib/slideout/slideout.js"></script>
  

  
    <script type="text/javascript" src="/lib/fancybox/jquery.fancybox.pack.js"></script>
  


    <script type="text/javascript" src="/js/src/even.js?v=2.6.0"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=2.6.0"></script>

  </body>
</html>
